'''
Created on Aug 14, 2012

@author: agaliull

Generate arguments for VLDB, Journal and PCEPS versions
'''
import subprocess

'''
Perturbation Args
'''

java = ['java', '-Xmx500m', '-jar']
schema_dir = "schema/schema"
fds_dir = "schema/fds"
data_dir = "/home/artur/workspace/data/uis/"
out = "results/perturbation/"

errors = ['0', '5', '10', '15', '20', '25', '30']

algorithms = ['V', 'J', 'P']
#HOLISTIC cmd options
algs_opt = {'V': ['2', 'n', 'y', 'y'], 
            'J': ['5', 'y', 'n'], 
            'P': ['5000', '5']} 
algs_run = {'V': java + ['vldb.jar'], 
            'J': java + ['journal.jar'], 
            'P': ['./pceps']}

for alg in algorithms[2]: 
    for error in errors:

        print("Doing alg {} error {}".format(alg, error))
    
        if (error != '5'):
            data = data_dir + "data_5000_" + error
        else:
            data = data_dir + "data_5000"
            
        out_file = out + alg + "_" + error
        
        run_cmd = []
        run_cmd += algs_run[alg]
        
        if (alg != 'P'):
            run_cmd.append('{}_{}'.format(schema_dir, alg))
            run_cmd.append('{}_{}'.format(fds_dir, alg))
        else:
            run_cmd.append('{}_{}'.format(schema_dir, alg))
            
        run_cmd.append('{}_clean'.format(data))
        run_cmd.append('{}_dirty'.format(data))
        run_cmd += algs_opt[alg]
        run_cmd.append(out_file)
        
        subprocess.call(run_cmd)
        #print(run_cmd)
        